home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
Libraries
/
VideoToolbox 96.06.15
/
VideoToolboxSources
/
MacMemory.c
< prev
next >
Wrap
Text File
|
1995-07-27
|
1KB
|
47 lines
/*
MacMemory.c
This is meant to be used in association with MacMemory.h, which redefines the
Standard C memory allocation functions to be implemented directly as calls to
the Macintosh Memory Manager. So don't write programs that explicitly call
"MacRealloc". This is for portable C programs that call "realloc", but which
will be compiled to use MacRealloc instead, for best performance on the Mac.
You use MacMemory.h by adding the line
#include "MacMemory.h"
either to your THINK/CodeWarrior C project prefix or to some header file that you
include in all your files.
HISTORY:
10/25/94 dgp deleted MacMemset() because it's no longer needed. CodeWarrior 4.5 works fine.
*/
#include "MacMemory.h"
#ifndef _STDLIB
#include <stdlib.h>
#endif
#ifndef _STDIO
#include <stdio.h>
#endif
#ifndef _STRING
#include <string.h>
#endif
#ifndef __MEMORY__
#include <Memory.h>
#endif
void *MacRealloc(void *oldPtr,size_t size)
{
void *newPtr;
if(oldPtr==NULL)return NewPtr(size);
SetPtrSize(oldPtr,size);
if(MemError()){
newPtr=NewPtr(size);
if(newPtr==NULL)return newPtr;
memcpy(newPtr,oldPtr,size);
DisposPtr(oldPtr);
}else newPtr=oldPtr;
return newPtr;
}